
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import java.util.HashMap;
import javax.swing.*;
import javax.swing.border.Border;

/**
 * @author Kaesar ALNIJRES
 */
public class TestLookAndFeel extends JFrame {

    private JPanel jPanel = null;
    private JPanel jPanel1 = null;
    private JPanel jPanel2 = null;
    private JButton jButton = null;
    private JButton jButton1 = null;
    private JCheckBox jCheckBox = null;
    private JCheckBox jCheckBox1 = null;
    private JList jList = null;
    private JComboBox jComboBox = null;
    private HashMap hashMap = new HashMap();
    private JSlider jSlider = null;
    private JTextArea jTextArea = null;

    public TestLookAndFeel() {
        super(); // optionnelle
        this.setSize(400, 300);
        this.setTitle("Test Look and Feel");
        UIManager.put("nimbusBase", Color.yellow);
        UIManager.put("nimbusBlueGrey", new Color(200, 217, 20));
        
      // UIManager.put("control", Color.lightGray);
        JPanel jPanel = new JPanel();
        jPanel.add(new JLabel("Label"));
        jButton = new JButton();
        jButton.setText("Bouton1");
        jButton.putClientProperty("JComponent.sizeVariant", "large");
        jPanel.add(jButton);

        jButton1 = new JButton();
        jButton1.setText("Bouton2");
        jButton1.putClientProperty("JComponent.sizeVariant", "small");

        jPanel.add(jButton1);

        jCheckBox = new JCheckBox("check1");

        jPanel.add(jCheckBox);
        jCheckBox1 = new JCheckBox("Check2");
        jPanel.add(jCheckBox1);
        jPanel1 = new JPanel();
        jPanel1.setLayout(new BorderLayout());
        jSlider = new JSlider();
        jPanel1.add(jSlider, BorderLayout.NORTH);
        jTextArea = new JTextArea();

        JScrollPane pane = new JScrollPane(jTextArea,
                ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jPanel1.add(pane, BorderLayout.CENTER);

        String[] sList = {"Article1", "Article2", "Article3", "Article4", "Article5"};
        jList = new JList(sList);
        jPanel2 = new JPanel(new GridLayout(2, 1));

        Border etched = BorderFactory.createEtchedBorder();
        Border titled = BorderFactory.createTitledBorder(etched, "Sélectionner un look");

        jPanel2.setBorder(titled);

        jPanel2.add(new JLabel("Les looks disponibles"));

        jComboBox = new JComboBox();
        jComboBox.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent e) {
                JComboBox cb = (JComboBox) e.getSource();
                String nom = (String) cb.getSelectedItem();
                System.out.println("nom= "+nom);
                String look = (String) hashMap.get(nom);
                System.out.println("loook hashMap.get(nom)= "+look);

                try {
                    UIManager.setLookAndFeel(look);
                    SwingUtilities.updateComponentTreeUI(TestLookAndFeel.this);
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        });

        UIManager.LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels();
        for (UIManager.LookAndFeelInfo info : infos) {
            String nom = info.getName();
            String nomClasse = info.getClassName();
            hashMap.put(nom, nomClasse);
            jComboBox.addItem(nom);
        }

        jPanel2.add(jComboBox);

//ATTENTION !!! l'appel add(...,...) était dans les versions précédant à 6 //getContentPane().add(jPanel,BorderLayout.NORTH);
        add(jPanel, BorderLayout.NORTH);
        add(jPanel1, BorderLayout.SOUTH);
        add(jList, BorderLayout.WEST);
        add(jPanel2, BorderLayout.CENTER);
    }
/*
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                TestLookAndFeel test = new TestLookAndFeel();
                test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                test.setVisible(true);
            }
        });

    }
    * */
    
}